package menu;

/**
 * build menu with array
 * @author yuanml
 */
public class ArrayMenuIterator implements Iterator {
    private int cursor = 0;
    private final MenuItem[] items;
    public ArrayMenuIterator(MenuItem[] items) {
        this.items = items;
    }

    @Override
    public boolean hasNext() {
        return ArrayMenu.MAX_ITEMS > cursor && items[cursor] != null;
    }

    @Override
    public Object next() {
        return items[cursor++];
    }
}
